﻿using Xtensive.Orm;

namespace DynamicLinqExtension.Model
{
  [HierarchyRoot]
  public class Order : Entity
  {
    [Key, Field]
    public long Id { get; private set; }

    [Field]
    public decimal ItemPrice { get; set; }

    [Field]
    public int ItemCount { get; set; }

    public override string ToString()
    {
      return string.Format("Order ({0}, TotalPrice={1})", Id, TotalPrice);
    }

    public decimal TotalPrice
    {
      get { return ItemCount * ItemPrice; }
    }

    public bool IsTotalPriceHigherThan(decimal value)
    {
      return TotalPrice > value;
    }

    public Order(Session session)
      : base(session)
    {
    }
  }
}